home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Actual 85 Febrero 2004.iso / Experto / Apache / apache_2.0.48-win32-x86-no_ssl.msi / Data.Cab / F252532_mod_include.html.en < prev    next >
Encoding:
Extensible Markup Language  |  2003-06-29  |  39.0 KB  |  769 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
  4.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  5.               This file is generated from xml source: DO NOT EDIT
  6.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  7.       -->
  8. <title>mod_include - Apache HTTP Server</title>
  9. <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
  10. <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
  11. <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
  12. <link href="../images/favicon.ico" rel="shortcut icon" /></head>
  13. <body>
  14. <div id="page-header">
  15. <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
  16. <p class="apache">Apache HTTP Server Version 2.0</p>
  17. <img alt="" src="../images/feather.gif" /></div>
  18. <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
  19. <div id="path">
  20. <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.0</a> > <a href="./">Modules</a></div>
  21. <div id="page-content">
  22. <div id="preamble"><h1>Apache Module mod_include</h1>
  23. <div class="toplang">
  24. <p><span>Available Languages: </span><a href="../en/mod/mod_include.html" title="English"> en </a> |
  25. <a href="../ja/mod/mod_include.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
  26. </div>
  27. <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Server-parsed html documents (Server Side Includes)</td></tr>
  28. <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
  29. <tr><th><a href="module-dict.html#ModuleIdentifier">ModuleáIdentifier:</a></th><td>include_module</td></tr>
  30. <tr><th><a href="module-dict.html#SourceFile">SourceáFile:</a></th><td>mod_include.c</td></tr>
  31. <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Implemented as an output filter since Apache
  32. 2.0</td></tr></table>
  33. <h3>Summary</h3>
  34.  
  35.     <p>This module provides a filter which will process files
  36.     before they are sent to the client. The processing is
  37.     controlled by specially formatted SGML comments, referred to as
  38.     <dfn>elements</dfn>. These elements allow conditional text, the
  39.     inclusion of other files or programs, as well as the setting and
  40.     printing of environment variables.</p>
  41. </div>
  42. <div id="quickview"><h3 class="directives">Directives</h3>
  43. <ul id="toc">
  44. <li><img alt="" src="../images/down.gif" /> <a href="#ssiendtag">SSIEndTag</a></li>
  45. <li><img alt="" src="../images/down.gif" /> <a href="#ssierrormsg">SSIErrorMsg</a></li>
  46. <li><img alt="" src="../images/down.gif" /> <a href="#ssistarttag">SSIStartTag</a></li>
  47. <li><img alt="" src="../images/down.gif" /> <a href="#ssitimeformat">SSITimeFormat</a></li>
  48. <li><img alt="" src="../images/down.gif" /> <a href="#ssiundefinedecho">SSIUndefinedEcho</a></li>
  49. <li><img alt="" src="../images/down.gif" /> <a href="#xbithack">XBitHack</a></li>
  50. </ul>
  51. <h3>Topics</h3>
  52. <ul id="topics">
  53. <li><img alt="" src="../images/down.gif" /> <a href="#enabling">Enabling Server-Side Includes</a></li>
  54. <li><img alt="" src="../images/down.gif" /> <a href="#pathinfo">PATH_INFO with Server Side Includes</a></li>
  55. <li><img alt="" src="../images/down.gif" /> <a href="#elements">Basic Elements</a></li>
  56. <li><img alt="" src="../images/down.gif" /> <a href="#includevars">Include Variables</a></li>
  57. <li><img alt="" src="../images/down.gif" /> <a href="#substitution">Variable Substitution</a></li>
  58. <li><img alt="" src="../images/down.gif" /> <a href="#flowctrl">Flow Control Elements</a></li>
  59. </ul><h3>See also</h3>
  60. <ul class="seealso">
  61. <li><code class="directive"><a href="../mod/core.html#options">Options</a></code></li>
  62. <li><code class="directive"><a href="../mod/core.html#acceptpathinfo">AcceptPathInfo</a></code></li>
  63. <li><a href="../misc/custom_errordocs.html">International Customized
  64. Server Error Messages</a></li>
  65. <li><a href="../filter.html">Filters</a></li>
  66. <li><a href="../howto/ssi.html">SSI Tutorial</a></li>
  67. </ul></div>
  68. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  69. <div class="section">
  70. <h2><a name="enabling" id="enabling">Enabling Server-Side Includes</a></h2>
  71.     
  72.  
  73.     <p>Server Side Includes are implemented by the
  74.     <code>INCLUDES</code> <a href="../filter.html">filter</a>. If
  75.     documents containing server-side include directives are given
  76.     the extension .shtml, the following directives will make Apache
  77.     parse them and assign the resulting document the mime type of
  78.     <code>text/html</code>:</p>
  79.  
  80.     <div class="example"><p><code>
  81.       AddType text/html .shtml<br />
  82.       AddOutputFilter INCLUDES .shtml
  83.     </code></p></div>
  84.  
  85.     <p>The following directive must be given for the directories
  86.     containing the shtml files (typically in a
  87.     <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> section,
  88.     but this directive is also valid in <code>.htaccess</code> files if
  89.     <code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code> <code>Options</code>
  90.     is set):</p>
  91.  
  92.     <div class="example"><p><code>
  93.       Options +Includes
  94.     </code></p></div>
  95.  
  96.     <p>For backwards compatibility, the <code>server-parsed</code>
  97.     <a href="../handler.html">handler</a> also activates the
  98.     INCLUDES filter. As well, Apache will activate the INCLUDES
  99.     filter for any document with mime type
  100.     <code>text/x-server-parsed-html</code> or
  101.     <code>text/x-server-parsed-html3</code> (and the resulting
  102.     output will have the mime type <code>text/html</code>).</p>
  103.  
  104.     <p>For more information, see our <a href="../howto/ssi.html">Tutorial on Server Side Includes</a>.</p>
  105. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  106. <div class="section">
  107. <h2><a name="pathinfo" id="pathinfo">PATH_INFO with Server Side Includes</a></h2>
  108.     
  109.  
  110.     <p>Files processed for server-side includes no longer accept
  111.     requests with <code>PATH_INFO</code> (trailing pathname information)
  112.     by default.  You can use the <code class="directive"><a href="../mod/core.html#acceptpathinfo">AcceptPathInfo</a></code> directive to
  113.     configure the server to accept requests with <code>PATH_INFO</code>.</p>
  114. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  115. <div class="section">
  116. <h2><a name="elements" id="elements">Basic Elements</a></h2>
  117.     <p>The document is parsed as an HTML document, with special
  118.     commands embedded as SGML comments. A command has the syntax: </p>
  119.  
  120.     <div class="example"><p><code>
  121.       <!--#<var>element</var> <var>attribute</var>=<var>value</var>
  122.       <var>attribute</var>=<var>value</var> ... -->
  123.     </code></p></div>
  124.  
  125.     <p>The value will often be enclosed in double quotes, but single
  126.     quotes (<code>'</code>) and backticks (<code>`</code>) are also
  127.     possible. Many commands only allow a single attribute-value pair.
  128.     Note that the comment terminator (<code>--></code>) should be
  129.     preceded by whitespace to ensure that it isn't considered part of
  130.     an SSI token. The allowed elements are listed in the following
  131.     table:</p>
  132.  
  133.     <table class="bordered">
  134.     <tr><th>Element</th><th>Description</th></tr>
  135.     <tr><td><code><a href="#element.config">config</a></code></td>
  136.         <td>configure output formats</td></tr>
  137.     <tr><td><code><a href="#element.echo">echo</a></code></td>
  138.         <td>print variables</td></tr>
  139.     <tr><td><code><a href="#element.exec">exec</a></code></td>
  140.         <td>execute external programs</td></tr>
  141.     <tr><td><code><a href="#element.fsize">fsize</a></code></td>
  142.         <td>print size of a file</td></tr>
  143.     <tr><td><code><a href="#element.flastmod">flastmod</a></code></td>
  144.         <td>print last modification time of a file</td></tr>
  145.     <tr><td><code><a href="#element.include">include</a></code></td>
  146.         <td>include a file</td></tr>
  147.     <tr><td><code><a href="#element.printenv">printenv</a></code></td>
  148.         <td>print all available variables</td></tr>
  149.     <tr><td><code><a href="#element.set">set</a></code></td>
  150.         <td>set a value of a variable</td></tr>
  151.     </table>
  152.  
  153.     <p>SSI elements may be defined by modules other than
  154.     <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>. In fact, the <code><a href="#element.exec">exec</a></code> element is provided by
  155.     <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code>, and will only be available if this
  156.     module is loaded.</p>
  157.  
  158.     <h3><a name="element.config" id="element.config">The config Element</a></h3>
  159.       <p>This command controls various aspects of the parsing. The
  160.       valid attributes are:</p>
  161.  
  162.       <dl>
  163.       <dt><code>errmsg</code></dt>
  164.       <dd>The value is a message that is sent back to the
  165.       client if an error occurs while parsing the
  166.       document.</dd>
  167.  
  168.       <dt><code>sizefmt</code></dt>
  169.       <dd>The value sets the format to be used which displaying
  170.       the size of a file. Valid values are <code>bytes</code>
  171.       for a count in bytes, or <code>abbrev</code> for a count
  172.       in Kb or Mb as appropriate, for example a size of 1024 bytes
  173.       will be printed as "1K".</dd>
  174.  
  175.       <dt><code>timefmt</code></dt>
  176.       <dd>The value is a string to be used by the
  177.       <code>strftime(3)</code> library routine when printing
  178.       dates.</dd>
  179.       </dl>
  180.      
  181.  
  182.     <h3><a name="element.echo" id="element.echo">The echo Element</a></h3>
  183.       <p>This command prints one of the <a href="#includevars">include
  184.       variables</a>, defined below. If the variable is unset, the result is
  185.       determined by the <code class="directive"><a href="#ssiundefinedecho">SSIUndefinedEcho</a></code> directive. Any dates printed are
  186.       subject to the currently configured <code>timefmt</code>.</p>
  187.  
  188.       <p>Attributes:</p> 
  189.  
  190.       <dl>
  191.       <dt><code>var</code></dt>
  192.       <dd>The value is the name of the variable to print.</dd>
  193.  
  194.       <dt><code>encoding</code></dt>
  195.       <dd><p>Specifies how Apache should encode special characters
  196.       contained in the variable before outputting them. If set
  197.       to <code>none</code>, no encoding will be done. If set to
  198.       <code>url</code>, then URL encoding (also known as %-encoding;
  199.       this is appropriate for use within URLs in links, etc.) will be
  200.       performed. At the start of an <code>echo</code> element,
  201.       the default is set to <code>entity</code>, resulting in entity
  202.       encoding (which is appropriate in the context of a block-level
  203.       HTML element, <em>e.g.</em> a paragraph of text). This can be
  204.       changed by adding an <code>encoding</code> attribute, which will
  205.       remain in effect until the next <code>encoding</code> attribute
  206.       is encountered or the element ends, whichever comes first.</p>
  207.  
  208.       <p>The <code>encoding</code> attribute must <em>precede</em> the
  209.       corresponding <code>var</code> attribute to be effective, and 
  210.       only special characters as defined in the ISO-8859-1 character
  211.       encoding will be encoded. This encoding process may not have the
  212.       desired result if a different character encoding is in use.</p>
  213.  
  214.       <div class="warning">
  215.         In order to avoid cross-site scripting issues, you should
  216.         <em>always</em> encode user supplied data.
  217.       </div>
  218.       </dd>
  219.       </dl>
  220.      
  221.  
  222.     <h3><a name="element.exec" id="element.exec">The exec Element</a></h3>
  223.       <p>The <code>exec</code> command executes a given shell command or
  224.       CGI script. It requires <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code> to be present
  225.       in the server. If <code class="directive"><a href="../mod/core.html#options">Options</a></code>
  226.       <code>IncludesNOEXEC</code> is set, this command is completely
  227.       disabled. The valid attributes are:</p>
  228.  
  229.       <dl>
  230.       <dt><code>cgi</code></dt>
  231.       <dd><p>The value specifies a (%-encoded) URL-path to
  232.       the CGI script. If the path does not begin with a slash (/),
  233.       then it is taken to be relative to the current
  234.       document. The document referenced by this path is
  235.       invoked as a CGI script, even if the server would not
  236.       normally recognize it as such. However, the directory
  237.       containing the script must be enabled for CGI scripts
  238.       (with <code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>
  239.       or <code class="directive"><a href="../mod/core.html#options">Options</a></code>
  240.       <code>ExecCGI</code>).</p>
  241.  
  242.       <p>The CGI script is given the <code>PATH_INFO</code> and query
  243.       string (<code>QUERY_STRING</code>) of the original request from the
  244.       client; these <em>cannot</em> be specified in the URL path. The
  245.       include variables will be available to the script in addition to
  246.       the standard <a href="mod_cgi.html">CGI</a> environment.</p>
  247.  
  248.       <div class="example"><h3>Example</h3><p><code>
  249.         <!--#exec cgi="/cgi-bin/example.cgi" -->
  250.       </code></p></div>
  251.  
  252.       <p>If the script returns a <code>Location:</code> header instead of
  253.       output, then this will be translated into an HTML anchor.</p>
  254.  
  255.       <p>The <code><a href="#includevirtual">include virtual</a></code>
  256.       element should be used in preference to <code>exec cgi</code>. In
  257.       particular, if you need to pass additional arguments to a CGI program,
  258.       using the query string, this cannot be done with <code>exec
  259.       cgi</code>, but can be done with <code>include virtual</code>, as
  260.       shown here:</p>
  261.  
  262.       <div class="example"><p><code>
  263.         <!--#include virtual="/cgi-bin/example.cgi?argument=value" -->
  264.       </code></p></div>
  265.       </dd>
  266.  
  267.       <dt><code>cmd</code></dt>
  268.       <dd><p>The server will execute the given string using
  269.       <code>/bin/sh</code>. The <a href="#includevars">include variables</a> are available to the command, in addition
  270.       to the usual set of CGI variables.</p>
  271.  
  272.       <p>The use of <code><a href="#includevirtual">#include virtual</a></code> is almost always prefered to using
  273.       either <code>#exec cgi</code> or <code>#exec cmd</code>. The former
  274.       (<code>#include virtual</code>) uses the standard Apache sub-request
  275.       mechanism to include files or scripts. It is much better tested and
  276.       maintained.</p>
  277.  
  278.       <p>In addition, on some platforms, like Win32, and on unix when
  279.       using <a href="../suexec.html">suexec</a>, you cannot pass arguments
  280.       to a command in an <code>exec</code> directive, or otherwise include
  281.       spaces in the command. Thus, while the following will work under a
  282.       non-suexec configuration on unix, it will not produce the desired
  283.       result under Win32, or when running suexec:</p>
  284.  
  285.       <div class="example"><p><code>
  286.         <!--#exec cmd="perl /path/to/perlscript arg1 arg2" -->
  287.       </code></p></div>
  288.       </dd>
  289.       </dl>
  290.      
  291.  
  292.     <h3><a name="element.fsize" id="element.fsize">The fsize Element</a></h3>
  293.       <p>This command prints the size of the specified file, subject
  294.       to the <code>sizefmt</code> format specification. Attributes:</p>
  295.  
  296.       <dl>
  297.       <dt><code>file</code></dt>
  298.       <dd>The value is a path relative to the directory
  299.       containing the current document being parsed.</dd>
  300.  
  301.       <dt><code>virtual</code></dt>
  302.       <dd>The value is a (%-encoded) URL-path. If it does not begin with
  303.       a slash (/) then it is taken to be relative to the current document.
  304.       Note, that this does <em>not</em> print the size of any CGI output,
  305.       but the size of the CGI script itself.</dd>
  306.       </dl>
  307.      
  308.  
  309.     <h3><a name="element.flastmod" id="element.flastmod">The flastmod Element</a></h3>
  310.       <p>This command prints the last modification date of the
  311.       specified file, subject to the <code>timefmt</code> format
  312.       specification. The attributes are the same as for the
  313.       <code><a href="#element.fsize">fsize</a></code> command.</p>
  314.      
  315.  
  316.     <h3><a name="element.include" id="element.include">The include Element</a></h3>
  317.       <p>This command inserts the text of another document or file
  318.       into the parsed file. Any included file is subject to the
  319.       usual access control. If the directory containing the
  320.       parsed file has <a href="core.html#options">Options</a>
  321.       <code>IncludesNOEXEC</code> set, then only documents with
  322.       a text MIME type (<code>text/plain</code>, <code>text/html</code>
  323.       etc.) will be included. Otherwise CGI scripts are invoked as normal
  324.       using the complete URL given in the command, including any query
  325.       string.</p>
  326.  
  327.       <p>An attribute defines the location of the document; the
  328.       inclusion is done for each attribute given to the include
  329.       command. The valid attributes are:</p>
  330.  
  331.       <dl>
  332.       <dt><code>file</code></dt>
  333.       <dd>The value is a path relative to the directory
  334.       containing the current document being parsed. It cannot
  335.       contain <code>../</code>, nor can it be an absolute path.
  336.       Therefore, you cannot include files that are outside of the
  337.       document root, or above the current document in the directory
  338.       structure. The <code>virtual</code> attribute should always be
  339.       used in preference to this one.</dd>
  340.  
  341.       <dt><code><a id="includevirtual" name="includevirtual">virtual</a></code></dt>
  342.       <dd><p>The value is a (%-encoded) URL-path. The URL cannot contain a
  343.       scheme or hostname, only a path and an optional query string. If it
  344.       does not begin with a slash (/) then it is taken to be relative to the
  345.       current document.</p>
  346.  
  347.       <p>A URL is constructed from the attribute, and the output the
  348.       server would return if the URL were accessed by the client is
  349.       included in the parsed output. Thus included files can be nested.</p>
  350.  
  351.       <p>If the specified URL is a CGI program, the program will be
  352.       executed and its output inserted in place of the directive in the
  353.       parsed file. You may include a query string in a CGI url:</p>
  354.      
  355.       <div class="example"><p><code>
  356.         <!--#include virtual="/cgi-bin/example.cgi?argument=value" -->
  357.       </code></p></div>
  358.            
  359.       <p><code>include virtual</code> should be used in preference
  360.       to <code>exec cgi</code> to include the output of CGI programs
  361.       into an HTML document.</p>
  362.       </dd>
  363.       </dl>
  364.      
  365.  
  366.     <h3><a name="element.printenv" id="element.printenv">The printenv Element</a></h3>
  367.       <p>This prints out a listing of all existing variables and
  368.       their values. Special characters are entity encoded (see the <code><a href="#element.echo">echo</a></code> element for details)
  369.       before being output. There are no attributes.</p>
  370.  
  371.       <div class="example"><h3>Example</h3><p><code>
  372.         <!--#printenv -->
  373.       </code></p></div>
  374.      
  375.  
  376.     <h3><a name="element.set" id="element.set">The set Element</a></h3>
  377.       <p>This sets the value of a variable. Attributes:</p>
  378.  
  379.       <dl>
  380.       <dt><code>var</code></dt>
  381.       <dd>The name of the variable to set.</dd>
  382.  
  383.       <dt><code>value</code></dt>
  384.       <dd>The value to give a variable.</dd>
  385.       </dl>
  386.  
  387.       <div class="example"><h3>Example</h3><p><code>
  388.         <!--#set var="category" value="help" -->
  389.       </code></p></div>
  390.      
  391. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  392. <div class="section">
  393. <h2><a name="includevars" id="includevars">Include Variables</a></h2>
  394.     
  395.  
  396.     <p>In addition to the variables in the standard CGI environment,
  397.     these are available for the <code>echo</code> command, for
  398.     <code>if</code> and <code>elif</code>, and to any program
  399.     invoked by the document.</p>
  400.  
  401.     <dl>
  402.       <dt><code>DATE_GMT</code></dt>
  403.       <dd>The current date in Greenwich Mean Time.</dd>
  404.  
  405.       <dt><code>DATE_LOCAL</code></dt>
  406.       <dd>The current date in the local time zone.</dd>
  407.  
  408.       <dt><code>DOCUMENT_NAME</code></dt>
  409.       <dd>The filename (excluding directories) of the document
  410.       requested by the user.</dd>
  411.  
  412.       <dt><code>DOCUMENT_URI</code></dt>
  413.       <dd>The (%-decoded) URL path of the document requested by the
  414.       user. Note that in the case of nested include files, this is
  415.       <em>not</em> the URL for the current document.</dd>
  416.  
  417.       <dt><code>LAST_MODIFIED</code></dt>
  418.       <dd>The last modification date of the document requested by
  419.       the user.</dd>
  420.  
  421.       <dt><code>QUERY_STRING_UNESCAPED</code></dt>
  422.       <dd>If a query string is present, this variable contains the
  423.       (%-decoded) query string, which is <em>escaped</em> for shell
  424.       usage (special characters like <code>&</code> etc. are
  425.       preceded by backslashes).</dd>
  426.     </dl>
  427. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  428. <div class="section">
  429. <h2><a name="substitution" id="substitution">Variable Substitution</a></h2>
  430.  
  431.     <p>Variable substitution is done within quoted strings in most
  432.     cases where they may reasonably occur as an argument to an SSI
  433.     directive. This includes the <code>config</code>,
  434.     <code>exec</code>, <code>flastmod</code>, <code>fsize</code>,
  435.     <code>include</code>, <code>echo</code>, and <code>set</code>
  436.     directives, as well as the arguments to conditional operators.
  437.     You can insert a literal dollar sign into the string using backslash
  438.     quoting:</p>
  439.  
  440.     <div class="example"><p><code>
  441.       <!--#if expr="$a = \$test" -->
  442.     </code></p></div>
  443.  
  444.     <p>If a variable reference needs to be substituted in the
  445.     middle of a character sequence that might otherwise be
  446.     considered a valid identifier in its own right, it can be
  447.     disambiguated by enclosing the reference in braces,
  448.     <em>a la</em> shell substitution:</p>
  449.  
  450.     <div class="example"><p><code>
  451.       <!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" -->
  452.     </code></p></div>
  453.  
  454.     <p>This will result in the <code>Zed</code> variable being set
  455.     to "<code>X_Y</code>" if <code>REMOTE_HOST</code> is
  456.     "<code>X</code>" and <code>REQUEST_METHOD</code> is
  457.     "<code>Y</code>".</p>
  458.  
  459.     <p>The below example will print "in foo" if the
  460.     <code>DOCUMENT_URI</code> is <code>/foo/file.html</code>, "in bar"
  461.     if it is <code>/bar/file.html</code> and "in neither" otherwise:</p>
  462.  
  463.     <div class="example"><p><code>
  464.       <!--#if expr='"$DOCUMENT_URI" = "/foo/file.html"' --><br />
  465.       <span class="indent">
  466.         in foo<br />
  467.       </span>
  468.       <!--#elif expr='"$DOCUMENT_URI" = "/bar/file.html"' --><br />
  469.       <span class="indent">
  470.         in bar<br />
  471.       </span>
  472.       <!--#else --><br />
  473.       <span class="indent">
  474.         in neither<br />
  475.       </span>
  476.       <!--#endif -->
  477.     </code></p></div>
  478. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  479. <div class="section">
  480. <h2><a name="flowctrl" id="flowctrl">Flow Control Elements</a></h2>
  481.     
  482.  
  483.     <p>The basic flow control elements are:</p>
  484.  
  485.     <div class="example"><p><code>
  486.       <!--#if expr="<var>test_condition</var>" --><br />
  487.       <!--#elif expr="<var>test_condition</var>" --><br />
  488.       <!--#else --><br />
  489.       <!--#endif -->
  490.     </code></p></div>
  491.  
  492.     <p>The <code>if</code> element works like an if statement in a
  493.     programming language. The test condition is evaluated and if
  494.     the result is true, then the text until the next <code>elif</code>,
  495.     <code>else</code> or <code>endif</code> element is included in the
  496.     output stream.</p>
  497.  
  498.     <p>The <code>elif</code> or <code>else</code> statements are be used
  499.     to put text into the output stream if the original
  500.     <var>test_condition</var> was false. These elements are optional.</p>
  501.  
  502.     <p>The <code>endif</code> element ends the <code>if</code> element
  503.     and is required.</p>
  504.  
  505.     <p><var>test_condition</var> is one of the following:</p>
  506.  
  507.     <dl>
  508.       <dt><code><var>string</var></code></dt>
  509.       <dd>true if <var>string</var> is not empty</dd>
  510.  
  511.       <dt><code><var>string1</var> = <var>string2</var><br />
  512.       <var>string1</var> != <var>string2</var></code></dt>
  513.       
  514.       <dd><p>Compare <var>string1</var> with <var>string2</var>. If
  515.       <var>string2</var> has the form <code>/<var>string2</var>/</code>
  516.       then it is treated as a regular expression. Regular expressions are
  517.       implemented by the <a href="http://www.pcre.org">PCRE</a> engine and
  518.       have the same syntax as those in <a href="http://www.perl.com">perl
  519.       5</a>.</p>
  520.  
  521.       <p>If you are matching positive (<code>=</code>), you can capture
  522.       grouped parts of the regular expression. The captured parts are
  523.       stored in the special variables <code>$1</code> ..
  524.       <code>$9</code>.</p>
  525.  
  526.       <div class="example"><h3>Example</h3><p><code>
  527.         <!--#if expr="$QUERY_STRING = /^sid=([a-zA-Z0-9]+)/" --><br />
  528.         <span class="indent">
  529.           <!--#set var="session" value="$1" --><br />
  530.         </span>
  531.         <!--#endif -->
  532.       </code></p></div>
  533.       </dd>
  534.  
  535.       <dt><code><var>string1</var> < <var>string2</var><br />
  536.        <var>string1</var> <= <var>string2</var><br />
  537.        <var>string1</var> > <var>string2</var><br />
  538.        <var>string1</var> >= <var>string2</var></code></dt>
  539.  
  540.       <dd>Compare <var>string1</var> with <var>string2</var>. Note, that
  541.       strings are compared <em>literally</em> (using
  542.       <code>strcmp(3)</code>). Therefore the string "100" is less than
  543.       "20".</dd>
  544.  
  545.       <dt><code>( <var>test_condition</var> )</code></dt>
  546.       <dd>true if <var>test_condition</var> is true</dd>
  547.  
  548.       <dt><code>! <var>test_condition</var></code></dt>
  549.       <dd>true if <var>test_condition</var> is false</dd>
  550.  
  551.       <dt><code><var>test_condition1</var> &&
  552.         <var>test_condition2</var></code></dt>
  553.       <dd>true if both <var>test_condition1</var> and
  554.       <var>test_condition2</var> are true</dd>
  555.  
  556.       <dt><code><var>test_condition1</var> ||
  557.         <var>test_condition2</var></code></dt>
  558.       <dd>true if either <var>test_condition1</var> or
  559.       <var>test_condition2</var> is true</dd>
  560.     </dl>
  561.  
  562.     <p>"<code>=</code>" and "<code>!=</code>" bind more tightly than
  563.     "<code>&&</code>" and "<code>||</code>". "<code>!</code>" binds
  564.     most tightly. Thus, the following are equivalent:</p>
  565.  
  566.     <div class="example"><p><code>
  567.       <!--#if expr="$a = test1 && $b = test2" --><br />
  568.       <!--#if expr="($a = test1) && ($b = test2)" -->
  569.     </code></p></div>
  570.  
  571.     <p>Anything that's not recognized as a variable or an operator
  572.     is treated as a string. Strings can also be quoted:
  573.     <code>'string'</code>. Unquoted strings can't contain whitespace
  574.     (blanks and tabs) because it is used to separate tokens such as
  575.     variables. If multiple strings are found in a row, they are
  576.     concatenated using blanks. So,</p>
  577.  
  578.     <div class="example"><p><code><var>string1</var>    <var>string2</var></code> results in <code><var>string1</var> <var>string2</var></code><br />
  579.       <br />
  580.       and<br />
  581.       <br />
  582.       <code>'<var>string1</var>    <var>string2</var>'</code> results in <code><var>string1</var>    <var>string2</var></code>.</p></div>
  583. </div>
  584. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  585. <div class="directive-section"><h2><a name="SSIEndTag" id="SSIEndTag">SSIEndTag</a> <a name="ssiendtag" id="ssiendtag">Directive</a></h2>
  586. <table class="directive">
  587. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>String that ends an include element</td></tr>
  588. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIEndTag <var>tag</var></code></td></tr>
  589. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIEndTag "-->"</code></td></tr>
  590. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  591. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  592. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  593. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  594. </table>
  595.     <p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
  596.     looks for to mark the end of an include element.</p>
  597.  
  598.     <div class="example"><h3>Example</h3><p><code>
  599.       SSIEndTag "%>"
  600.     </code></p></div>
  601.  
  602.  
  603. <h3>See also</h3>
  604. <ul>
  605. <li><code class="directive"><a href="#ssistarttag">SSIStartTag</a></code></li>
  606. </ul>
  607. </div>
  608. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  609. <div class="directive-section"><h2><a name="SSIErrorMsg" id="SSIErrorMsg">SSIErrorMsg</a> <a name="ssierrormsg" id="ssierrormsg">Directive</a></h2>
  610. <table class="directive">
  611. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Error message displayed when there is an SSI
  612. error</td></tr>
  613. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIErrorMsg <var>message</var></code></td></tr>
  614. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIErrorMsg "[an error occurred while processing this
  615. directive]"</code></td></tr>
  616. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  617. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
  618. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  619. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  620. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  621. </table>
  622.     <p>The <code class="directive">SSIErrorMsg</code> directive changes the error
  623.     message displayed when <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> encounters an
  624.     error. For production servers you may consider changing the default
  625.     error message to <code>"<!-- Error -->"</code> so that
  626.     the message is not presented to the user.</p>
  627.  
  628.     <p>This directive has the same effect as the <code><!--#config
  629.     errmsg=<var>message</var> --></code> element.</p>
  630.  
  631.     <div class="example"><h3>Example</h3><p><code>
  632.       SSIErrorMsg "<!-- Error -->"
  633.     </code></p></div>
  634.  
  635. </div>
  636. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  637. <div class="directive-section"><h2><a name="SSIStartTag" id="SSIStartTag">SSIStartTag</a> <a name="ssistarttag" id="ssistarttag">Directive</a></h2>
  638. <table class="directive">
  639. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>String that starts an include element</td></tr>
  640. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIStartTag <var>tag</var></code></td></tr>
  641. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIStartTag "<!--#"</code></td></tr>
  642. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  643. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  644. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  645. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  646. </table>
  647.     <p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
  648.     looks for to mark an include element to process.</p>
  649.  
  650.     <p>You may want to use this option if you have 2 servers parsing the
  651.     output of a file each processing different commands (possibly at
  652.     different times).</p> 
  653.  
  654.     <div class="example"><h3>Example</h3><p><code>
  655.       SSIStartTag "<%"
  656.     </code></p></div>
  657.  
  658.     <p>The example given above, in conjunction with a matching
  659.     <code class="directive"><a href="#ssiendtag">SSIEndTag</a></code>, will 
  660.     allow you to use SSI directives as shown in the example 
  661.     below:</p>
  662.  
  663.     <div class="example"><h3>SSI directives with alternate start and end tags</h3><p><code>
  664.       <%printenv %>
  665.     </code></p></div>
  666.  
  667. <h3>See also</h3>
  668. <ul>
  669. <li><code class="directive"><a href="#ssiendtag">SSIEndTag</a></code></li>
  670. </ul>
  671. </div>
  672. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  673. <div class="directive-section"><h2><a name="SSITimeFormat" id="SSITimeFormat">SSITimeFormat</a> <a name="ssitimeformat" id="ssitimeformat">Directive</a></h2>
  674. <table class="directive">
  675. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Configures the format in which date strings are
  676. displayed</td></tr>
  677. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSITimeFormat <var>formatstring</var></code></td></tr>
  678. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSITimeFormat "%A, %d-%b-%Y %H:%M:%S %Z"</code></td></tr>
  679. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  680. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
  681. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  682. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  683. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  684. </table>
  685. <p>This directive changes the format in which date strings are displayed 
  686.     when echoing <code>DATE</code> environment variables. The
  687.     <var>formatstring</var> is as in <code>strftime(3)</code> from the
  688.     C standard library.</p>
  689.  
  690.     <p>This directive has the same effect as the <code><!--#config
  691.     timefmt=<var>formatstring</var> --></code> element.</p>
  692.  
  693.     <div class="example"><h3>Example</h3><p><code>
  694.       SSITimeFormat "%R, %B %d, %Y"
  695.     </code></p></div>
  696.  
  697.     <p>The above directive would cause times to be displayed in the
  698.     format "22:26, June 14, 2002".</p>
  699.  
  700. </div>
  701. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  702. <div class="directive-section"><h2><a name="SSIUndefinedEcho" id="SSIUndefinedEcho">SSIUndefinedEcho</a> <a name="ssiundefinedecho" id="ssiundefinedecho">Directive</a></h2>
  703. <table class="directive">
  704. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>String displayed when an unset variable is echoed</td></tr>
  705. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIUndefinedEcho <var>string</var></code></td></tr>
  706. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIUndefinedEcho "(none)"</code></td></tr>
  707. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  708. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  709. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  710. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.34 and later.</td></tr>
  711. </table>
  712.     <p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
  713.     displays when a variable is not set and "echoed".</p>
  714.  
  715.     <div class="example"><h3>Example</h3><p><code>
  716.       SSIUndefinedEcho "<!-- undef -->"
  717.     </code></p></div>
  718.  
  719. </div>
  720. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  721. <div class="directive-section"><h2><a name="XBitHack" id="XBitHack">XBitHack</a> <a name="xbithack" id="xbithack">Directive</a></h2>
  722. <table class="directive">
  723. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Parse SSI directives in files with the execute bit
  724. set</td></tr>
  725. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>XBitHack on|off|full</code></td></tr>
  726. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>XBitHack off</code></td></tr>
  727. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  728. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Options</td></tr>
  729. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  730. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  731. </table>
  732.     <p>The <code class="directive">XBitHack</code> directive controls the parsing
  733.     of ordinary html documents. This directive only affects files associated
  734.     with the MIME type <code>text/html</code>. <code class="directive">XBitHack</code> can take on the following values:</p>
  735.  
  736.     <dl>
  737.       <dt><code>off</code></dt>
  738.       <dd>No special treatment of executable files.</dd>
  739.  
  740.       <dt><code>on</code></dt>
  741.       <dd>Any <code>text/html</code> file that has the user-execute bit
  742.       set will be treated as a server-parsed html document.</dd>
  743.  
  744.       <dt><code>full</code></dt>
  745.       <dd>As for <code>on</code> but also test the group-execute bit.
  746.       If it is set, then set the <code>Last-modified</code> date of the
  747.       returned file to be the last modified time of the file. If
  748.       it is not set, then no last-modified date is sent. Setting
  749.       this bit allows clients and proxies to cache the result of
  750.       the request. 
  751.  
  752.       <div class="note"><h3>Note</h3>
  753.       <p>You would not want to use the full option, unless you assure the
  754.       group-execute bit is unset for every SSI script which might <code>#include</code> a CGI or otherwise produces different output on
  755.       each hit (or could potentially change on subsequent requests).</p>
  756.       </div>
  757.       </dd>
  758.     </dl>
  759.  
  760.     
  761. </div>
  762. </div>
  763. <div class="bottomlang">
  764. <p><span>Available Languages: </span><a href="../en/mod/mod_include.html" title="English"> en </a> |
  765. <a href="../ja/mod/mod_include.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
  766. </div><div id="footer">
  767. <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
  768. <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
  769. </body></html>